package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.CorpWeChatUser;
import com.shrcl.engineerprocess.domain.CorpWeChatUserDAO;
import com.shrcl.engineerprocess.domain.impl.CorpWeChatUserImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.CorpWeChatUserDAO")
public class CorpWeChatUserDAOImpl extends BaseDAOService<CorpWeChatUser> implements CorpWeChatUserDAO {
  public CorpWeChatUser findActiveWeChatUser(final String wechatuserid) {
    IGenericQuery<CorpWeChatUser> query=getObjectFactory().createGenericQuery(CorpWeChatUser.class,"select e from com.shrcl.engineerprocess.domain.impl.CorpWeChatUserImpl as e   where (((e.wechatuserid) = (:wechatuserid)) and ((e.excluded) = (false))) and  e.active = 1      ").setParameter("wechatuserid",wechatuserid);
    CorpWeChatUser _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
  
  public CorpWeChatUser findWeChatUser(final String wechatuserid) {
    IGenericQuery<CorpWeChatUser> query=getObjectFactory().createGenericQuery(CorpWeChatUser.class,"select e from com.shrcl.engineerprocess.domain.impl.CorpWeChatUserImpl as e   where ((e.wechatuserid) = (:wechatuserid)) and  e.active = 1      ").setParameter("wechatuserid",wechatuserid);
    CorpWeChatUser _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
  
  public CorpWeChatUser create(final Procedure1<? super CorpWeChatUser> init) {CorpWeChatUser corpWeChatUser=CorpWeChatUserImpl.create(getObjectFactory());
    final Procedure1<CorpWeChatUser> _function = new Procedure1<CorpWeChatUser>() {
        public void apply(final CorpWeChatUser it) {
          init.apply(it);
          it.checkValid();
        }
      };
    CorpWeChatUser _doubleArrow = ObjectExtensions.<CorpWeChatUser>operator_doubleArrow(corpWeChatUser, _function);
    return _doubleArrow;
  }
}
